<?php

namespace App\Admin\show;

use App\Models\GrIntegral;
use Dcat\Admin\Support\LazyRenderable;
use Dcat\Admin\Widgets\Table;

class UserIntegral extends LazyRenderable
{

    public function render()
    {
        // 获取ID
        $id = $this->user_id;
        $data=GrIntegral::where('user_id',$id)->get(['integral_id', 'integral_number', 'integral_type','is_Increase','created_at']);
        $data=$data->toArray();
        foreach ($data as $key=>$val){
            if($val['integral_type']==0){
                $data[$key]['integral_type']='签到';
            }else if($val['integral_type']==1){
                $data[$key]['integral_type']='抽奖';
            }else{
                $data[$key]['integral_type']='补签';
            }
            if($val['is_Increase']==0) {
                $data[$key]['is_Increase'] = '增加';
            }else{
                $data[$key]['is_Increase']='减少';
            }
        }
        $titles = [
            '积分id',
            '积分数量',
            '积分来源',
            '积分增减类型',
            '积分增减时间',
        ];

        return Table::make($titles, $data);
    }


}
